
[Setup]
AppId=<%= "weh-iss-"+config.id %>
AppName=<%= config.name %>
AppVerName=<%= config.name %> <%= manifest.version %>
AppPublisher=<%= config.win.appPublisher || manifest.homepage %>
AppPublisherURL=<%= config.win.appPublisherURL || manifest.homepage %>
AppSupportURL=<%= config.win.appSupportURL || manifest.homepage %>
AppUpdatesURL=<%= config.win.appUpdatesURL || manifest.homepage %>
DefaultDirName={pf}\<%= config.id %>
DefaultGroupName=<%= config.id %>
DisableProgramGroupPage=yes
<% if(config.win.licenseFile) { %>
LicenseFile=<%= config.win.licenseFile %>
<% } %>
<% if(config.win.infoPost) { %>
	InfoAfterFile=<%= config.win.infoPost %>
<% } %>
OutputDir=<%= basedir %>\builds
OutputBaseFilename=<%= config.name %>Setup-<%= manifest.version %>
Compression=lzma
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64
ShowUndisplayableLanguages=yes

[InstallDelete]
Type: filesandordirs; Name: "{app}\bin"
Type: filesandordirs; Name: "{app}\converter"
Type: files; Name: "{app}\*.json"
Type: files; Name: "{app}\*.txt"

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: fr; MessagesFile: "compiler:Languages\French.isl"
Name: de; MessagesFile: "compiler:Languages\German.isl"
Name: es; MessagesFile: "compiler:Languages\Spanish.isl"
Name: it; MessagesFile: "compiler:Languages\Italian.isl"
Name: "ptPT"; MessagesFile: "compiler:Languages\Portuguese.isl"
Name: "ptBR"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"

[Files]
Source: bin\<%= config.id %>-win-64.exe; DestDir: "{app}\\bin"; Check: IsX64;
Source: bin\<%= config.id %>-win-32.exe; DestDir: "{app}\\bin"; Check: IsOtherArch;
Source: firefox.64.<%= config.id %>.json; DestDir: "{app}"; DestName: "firefox.<%= config.id %>.json"; Check: IsX64;
Source: firefox.32.<%= config.id %>.json; DestDir: "{app}"; DestName: "firefox.<%= config.id %>.json"; Check: IsOtherArch;
Source: chrome.64.<%= config.id %>.json; DestDir: "{app}"; DestName: "chrome.<%= config.id %>.json"; Check: IsX64;
Source: chrome.32.<%= config.id %>.json; DestDir: "{app}"; DestName: "chrome.<%= config.id %>.json"; Check: IsOtherArch;
Source: edge.64.<%= config.id %>.json; DestDir: "{app}"; DestName: "edge.<%= config.id %>.json"; Check: IsX64;
Source: edge.32.<%= config.id %>.json; DestDir: "{app}"; DestName: "edge.<%= config.id %>.json"; Check: IsOtherArch;

<% (config.win.sources || []).forEach((source)=>{ %>
Source: "<%= source.source %>"; <% 
	Object.keys(source).filter((key) => key!=="source").forEach((key)=>{
		%><%= key %>: <%- source[key] %>; <%
	}) %>

<% }) %>

[Registry]
Root: HKLM; Subkey: "Software\<%= config.win.appPublisher %>\<%= config.id %>"; Flags: uninsdeletekey;
Root: HKLM; Subkey: "Software\<%= config.win.appPublisher %>\<%= config.id %>"; ValueType: string; ValueName: "InstallFolder"; ValueData: "{app}"; 
Root: HKLM; Subkey: "Software\<%= config.win.appPublisher %>\<%= config.id %>"; ValueType: string; ValueName: "Version"; ValueData: "<%= manifest.version %>"; 
Root: HKLM; Subkey: "Software\Mozilla\NativeMessagingHosts\<%= config.id %>"; ValueType: string; ValueName: ""; ValueData: "{app}\firefox.<%= config.id %>.json"; Flags: uninsdeletekey;
Root: HKLM; Subkey: "Software\Chromium\NativeMessagingHosts\<%= config.id %>"; ValueType: string; ValueName: ""; ValueData: "{app}\chrome.<%= config.id %>.json"; Flags: uninsdeletekey;
Root: HKLM; Subkey: "Software\Google\Chrome\NativeMessagingHosts\<%= config.id %>"; ValueType: string; ValueName: ""; ValueData: "{app}\chrome.<%= config.id %>.json"; Flags: uninsdeletekey;
Root: HKLM; Subkey: "Software\Microsoft\Edge\NativeMessagingHosts\<%= config.id %>"; ValueType: string; ValueName: ""; ValueData: "{app}\edge.<%= config.id %>.json"; Flags: uninsdeletekey;

[Code]
function IsX64: Boolean;
begin
  Result := Is64BitInstallMode and (ProcessorArchitecture = paX64);
end;

function IsOtherArch: Boolean;
begin
  Result := not IsX64;
end;
